package org.dromara.wms.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseService;
import org.dromara.wms.domain.WmsGroupProduct;
import org.dromara.wms.service.WmsGroupProductServiceImpl;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 产品分组子表
 *
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/wms/groupProduct")
public class WmsGroupProductController extends BaseService {

  private final WmsGroupProductServiceImpl groupProductService;

  /**
   * 查询
   */
  @SaCheckPermission("wms:groupProduct:list")
  @GetMapping("/list")
  public TableDataInfo<WmsGroupProduct> list(WmsGroupProduct bo, PageQuery pageQuery) {
    return groupProductService.queryPageList(bo, pageQuery);
  }

  /**
   * 新增
   */
  @SaCheckPermission("wms:groupProduct:add")
  @Log(title = "产品分组", businessType = BusinessType.INSERT)
  @RepeatSubmit()
  @PostMapping()
  public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsGroupProduct[] bo) {
    return toAjax(groupProductService.insertByBo(bo));
  }

  /**
   * 删除
   */
  @SaCheckPermission("wms:groupProduct:remove")
  @Log(title = "产品分组", businessType = BusinessType.DELETE)
  @RepeatSubmit()
  @DeleteMapping("/delete")
  public R<Void> remove(@Param("bo") WmsGroupProduct bo) {
    return toAjax(groupProductService.delete(bo));
  }
}
